package IO.io_5_9;

import java.io.*;

/**
 * @author bruin_du
 * @description 复制文件
 * @date 2022/5/12 15:41
 **/
public class CopyFile {
    public static void main(String[] args) throws IOException {
        try(InputStream is = new FileInputStream("src.png")){
            try(OutputStream os = new FileOutputStream("dest.png")){
                byte[] buf = new byte[1024];
                while(true){
                    int n = is.read(buf);
                    if(n == -1)
                        break;
                    os.write(buf);
                }
                os.flush();
            }
        }
    }
}
